<script setup lang="ts">
import { ref, onMounted } from 'vue';

const logoJump = ref(false);
const carouselRef = ref<any>(null);

// 轮播图初始化后自动对齐
onMounted(() => {
  setTimeout(() => {
    carouselRef.value?.setActiveItem(0);
  }, 500);
});

//轮番图
const carouselItems = [
  {
    imgUrl: 'https://picsum.photos/id/431/1200/850',
    alt: '精美的甜点和咖啡'
  },
  {
    imgUrl: 'https://picsum.photos/id/425/1200/850',
    alt: '精致的提拉米苏甜点'
  },
  {
    imgUrl: 'https://picsum.photos/id/292/1200/850',
    alt: '精致汉堡和薯条'
  },
  {
    imgUrl: 'https://picsum.photos/id/312/1200/850',
    alt: '传统中式美食展示'
  },
  {
    imgUrl: 'https://picsum.photos/id/674/1200/850',
    alt: '新鲜海鲜拼盘'
  },
  {
    imgUrl: 'https://picsum.photos/id/488/1200/850',
    alt: '精美的法式牛排配红酒'
  },

  {
    imgUrl: 'https://picsum.photos/id/365/1200/850',
    alt: '丰盛的早餐搭配咖啡'
  },
  {
    imgUrl: 'https://picsum.photos/id/326/1200/850',
    alt: '色彩缤纷的水果沙拉'
  },
  {
    imgUrl: 'https://picsum.photos/id/493/1200/850',
    alt: '新鲜制作的意大利面'
  },
  {
    imgUrl: 'https://picsum.photos/id/429/1200/850',
    alt: '香浓的芝士披萨'
  },
];
</script>

<template>
  <div class="page-wrapper">
    <!-- 顶部导航区域 -->
    <header class="header-container">
      <div class="logo-container">
        <div
            class="logo"
            @mouseenter="logoJump = true"
            @mouseleave="logoJump = false"
        >
          <!-- 新对称式logo：对话气泡+单星星 -->
          <svg
              class="logo-icon"
              :class="{ 'jump': logoJump }"
              viewBox="0 0 48 48"
              fill="none"
          >
            <!-- 外层对称气泡形状 -->
            <path d="M12 24C12 15.1634 19.1634 8 28 8C36.8366 8 44 15.1634 44 24C44 32.8366 36.8366 40 28 40C23.5817 40 19.5291 38.2426 16.5858 35.2993L12 40V24Z"
                  stroke="#2563EB" stroke-width="2.5" fill="#EFF6FF"/>

            <!-- 中央评分星星 -->
            <path d="M24 14L26.5 22L34 22L28 26.5L30 34L24 30L18 34L20 26.5L14 22L21.5 22L24 14Z"
                  fill="#2563EB"/>
          </svg>
          <span class="logo-text" :class="{ 'jump': logoJump }">点评通</span>
        </div>
      </div>

      <!-- 登录按钮区域 -->
      <div class="login-buttons">
        <button class="login-btn merchant-btn group" onclick="window.location.href='/merchantLoginPage'">
          <span class="btn-text">我是商家</span>
          <span class="btn-icon">🏠</span>
        </button>
        <button class="login-btn user-btn group" onclick="window.location.href='/userLoginPage'">
          <span class="btn-text">我是用户</span>
          <span class="btn-icon">👤</span>
        </button>
      </div>
    </header>

    <!-- 轮播图区域 -->
    <div class="carousel-container">
      <el-carousel
          :interval="4000"
          type="card"
          height="450px"
          indicator-position="none"
          ref="carouselRef"
          :initial-index="0"
      >
        <el-carousel-item v-for="(item, index) in carouselItems" :key="index">
          <div class="carousel-item-wrapper">
            <img
                :src="item.imgUrl"
                :alt="item.alt"
                class="carousel-img"
                loading="lazy"
            >
            <div class="carousel-overlay"></div>
          </div>
        </el-carousel-item>
      </el-carousel>
    </div>

    <!-- 网站介绍区域 -->
    <section class="intro-section">
      <div class="intro-container">
        <h2 class="intro-title">关于点评通</h2>
        <div class="intro-subtitle">连接用户与商家的桥梁，让消费更透明</div>
        <div class="intro-content">
          <p class="intro-desc">
            点评通是国内领先的生活服务点评平台，致力于为用户提供真实、客观的商家评价与推荐，
            同时为商家提供高效的营销解决方案。无论您是想寻找优质商家，还是希望提升店铺知名度，
            点评通都能满足您的需求。
          </p>
          <div class="intro-features">
            <div class="feature-item">
              <div class="feature-icon">✓</div>
              <div class="feature-text">真实用户评价，杜绝虚假信息</div>
            </div>
            <div class="feature-item">
              <div class="feature-icon">✓</div>
              <div class="feature-text">多维度评分体系，精准反映商家实力</div>
            </div>
            <div class="feature-item">
              <div class="feature-icon">✓</div>
              <div class="feature-text">商家专属管理后台，高效运营店铺</div>
            </div>
            <div class="feature-item">
              <div class="feature-icon">✓</div>
              <div class="feature-text">海量用户流量，助力商家增长</div>
            </div>
            <div class="feature-item">
              <div class="feature-icon">✓</div>
              <div class="feature-text">专业数据分析，洞察用户需求</div>
            </div>
            <div class="feature-item">
              <div class="feature-icon">✓</div>
              <div class="feature-text">实时动态榜单，发现热门商家</div>
            </div>
            <div class="feature-item">
              <div class="feature-icon">✓</div>
              <div class="feature-text">便捷预约系统，一键到店消费</div>
            </div>
            <div class="feature-item">
              <div class="feature-icon">✓</div>
              <div class="feature-text">专属优惠活动，享受更多福利</div>
            </div>
            <div class="feature-item">
              <div class="feature-icon">✓</div>
              <div class="feature-text">7×24小时客服，随时解决问题</div>
            </div>
          </div>
          <div class="cta-container">
            <button class="cta-btn primary-cta" onclick="window.location.href='/userRegisterPage'">立即开始使用</button>
            <button class="cta-btn secondary-cta">了解更多功能</button>
          </div>
        </div>
      </div>
    </section>

    <!-- 页脚区域 -->
    <footer class="page-footer">
      <div class="footer-content">
        <div class="footer-links">
          <a href="#" class="footer-link">关于我们</a>
          <a href="#" class="footer-link">联系方式</a>
          <a href="#" class="footer-link">隐私政策</a>
          <a href="#" class="footer-link">用户协议</a>
        </div>
      </div>
    </footer>
  </div>
</template>

<style scoped lang="scss">
// 颜色系统保持一致
$primary: #2563EB;
$primary-light: #3B82F6;
$primary-dark: #1D4ED8;
$primary-bg: #EFF6FF;
$text-primary: #1E293B;
$text-secondary: #64748B;
$text-tertiary: #94A3B8;
$bg-light: #F8FAFC;
$white: #FFFFFF;
$shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
$shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.12);

.page-wrapper {
  background-color: $bg-light;
  min-height: 100vh;
  color: $text-primary;
  display: flex;
  flex-direction: column;
}

// 顶部导航样式
.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 50px;
  background: $white;
  box-shadow: $shadow;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: padding 0.3s ease;

  &.scrolled {
    padding: 12px 50px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
  }
}

// 调整后logo样式
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.3s ease;

  &:hover {
    transform: scale(1.02);
  }
}

.logo-icon {
  width: 42px;
  height: 42px;
  transition: all 0.3s ease;

  // 鼠标悬停时增加发光效果
  &.jump {
    filter: drop-shadow(0 0 8px rgba(37, 99, 235, 0.4));
    animation: rotate 1.5s ease-in-out;
  }
}

// 旋转动画
@keyframes rotate {
  0% { transform: rotate(0deg); }
  50% { transform: rotate(5deg) scale(1.05); }
  100% { transform: rotate(0deg); }
}

.logo-text {
  font-size: 26px;
  font-weight: 700;
  color: $primary;
  letter-spacing: -0.5px;
  transition: all 0.3s ease;
  font-family: 'Segoe UI', Roboto, sans-serif;
}

// 登录按钮样式
.login-buttons {
  display: flex;
  gap: 16px;
  align-items: center;
}

.login-btn {
  padding: 12px 26px;
  font-size: 16px;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  z-index: 1;

  .btn-text {
    transition: transform 0.3s ease;
  }

  .btn-icon {
    font-size: 18px;
    transition: transform 0.3s ease, color 0.3s ease;
  }

  &:hover {
    .btn-text {
      transform: translateX(-4px);
    }
    .btn-icon {
      transform: translateX(4px);
    }
  }
}

.merchant-btn {
  background-color: $primary-bg;
  color: $primary;
  position: relative;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(37, 99, 235, 0.05), transparent);
    transition: all 0.6s ease;
    z-index: -1;
  }

  &:hover {
    background-color: rgba(37, 99, 235, 0.12);
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(37, 99, 235, 0.1);

    &::before {
      left: 100%;
    }
  }
}

.user-btn {
  background-color: $primary;
  color: $white;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);

  &::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.1) 0%,
            rgba(255, 255, 255, 0) 50%,
            rgba(255, 255, 255, 0.1) 100%
    );
    background-size: 200% 100%;
    transition: background-position 0.6s ease;
    z-index: -1;
  }

  &:hover {
    background-color: $primary-dark;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.3);
    color: $white;

    &::after {
      background-position: -100% 0;
    }
  }
}

.login-btn:active {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

// 跳动动画
.jump {
  animation: bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

// 轮播图样式
.carousel-container {
  width: 88%;
  max-width: 1500px;
  margin: 30px auto 50px;
  padding: 0 20px;
  position: relative;
  margin-left: auto;
  margin-right: 6%;
}

::v-deep .el-carousel--card {
  width: 130% !important;
  margin: 0 -15%;

  .el-carousel__container {
    display: flex;
    justify-content: center;
    padding: 0;
  }

  .el-carousel__item--active {
    transform: scale(1.08);
    z-index: 3;
    margin: 0 8px;
    opacity: 1;
    box-shadow: $shadow-hover;
  }

  .el-carousel__item {
    height: 450px !important;
    width: calc(45% - 16px) !important;
    opacity: 1;
    transition: all 0.5s ease;

    &:nth-child(odd):not(.el-carousel__item--active) {
      transform: translateX(8%) scale(0.9);
    }

    &:nth-child(even):not(.el-carousel__item--active) {
      transform: translateX(-8%) scale(0.9);
    }
  }

  .el-carousel__item--card {
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.4s ease;
  }
}

.carousel-item-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

.carousel-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
}

.carousel-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to top, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0) 60%);
  border-radius: 14px;
  z-index: 1;
}

::v-deep .el-carousel__arrow {
  z-index: 10;
  width: 45px;
  height: 45px;
  background-color: rgba(255, 255, 255, 0.9);
  color: $primary;
  font-size: 22px;
  opacity: 0.85;
  transition: all 0.3s ease;

  &:hover {
    width: 48px;
    height: 48px;
    opacity: 1;
    background-color: white;
    box-shadow: $shadow;
  }

  &.el-carousel__arrow--left {
    left: 8%;
  }

  &.el-carousel__arrow--right {
    right: 8%;
  }
}

// 网站介绍区域样式
.intro-section {
  background-color: $white;
  padding: 90px 0 100px;
  margin-top: 40px;
  position: relative;
  flex-grow: 1;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 8px;
    background: linear-gradient(90deg, $primary-light, $primary);
  }
}

.intro-container {
  width: 85%;
  max-width: 1300px;
  margin: 0 auto;
}

.intro-title {
  font-size: 36px;
  color: $text-primary;
  text-align: center;
  margin-bottom: 12px;
  position: relative;
  font-weight: 700;
  letter-spacing: -0.5px;

  &::after {
    content: '';
    display: block;
    width: 100px;
    height: 5px;
    background: linear-gradient(90deg, $primary-light, $primary);
    margin: 20px auto 0;
    border-radius: 3px;
  }
}

.intro-subtitle {
  text-align: center;
  color: $text-secondary;
  font-size: 18px;
  margin-bottom: 40px;
  font-weight: 500;
}

.intro-content {
  max-width: 1000px;
  margin: 0 auto;
}

.intro-desc {
  font-size: 19px;
  color: $text-secondary;
  line-height: 1.8;
  text-align: center;
  margin-bottom: 60px;
  max-width: 900px;
  padding: 0 20px;
}

.intro-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  margin-bottom: 70px;
}

.feature-item {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 30px;
  background-color: $bg-light;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.03);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);

  &:hover {
    transform: translateY(-8px);
    box-shadow: $shadow-hover;
    background-color: $white;
    border-color: transparent;
  }
}

.feature-icon {
  font-size: 24px;
  color: $primary;
  font-weight: bold;
  background-color: $primary-bg;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.feature-item:hover .feature-icon {
  background-color: $primary;
  color: $white;
  transform: scale(1.1);
}

.feature-text {
  font-size: 17px;
  color: $text-primary;
  line-height: 1.7;
  font-weight: 500;
}

.cta-container {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 60px;
}

.cta-btn {
  padding: 14px 32px;
  font-size: 17px;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.35s ease;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.primary-cta {
  background-color: $primary;
  color: $white;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.25);

  &:hover {
    background-color: $primary-dark;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.35);
  }
}

.secondary-cta {
  background-color: $white;
  color: $primary;
  border: 1px solid $primary;

  &:hover {
    background-color: $primary-bg;
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(37, 99, 235, 0.1);
  }
}

// 页脚样式
.page-footer {
  background-color: $text-primary;
  color: $text-tertiary;
  padding: 40px 0;
  margin-top: auto;
}

.footer-content {
  width: 85%;
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.footer-links {
  display: flex;
  gap: 30px;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-link {
  color: $text-tertiary;
  text-decoration: none;
  font-size: 15px;
  transition: color 0.3s ease;
  padding: 5px 0;

  &:hover {
    color: $white;
  }
}

// 响应式优化
@media (max-width: 1200px) {
  .intro-features {
    gap: 24px;
  }
}

@media (max-width: 992px) {
  .intro-features {
    grid-template-columns: repeat(2, 1fr);
  }

  ::v-deep .el-carousel--card {
    width: 135% !important;
    margin: 0 -17.5%;
  }

  .cta-container {
    flex-direction: column;
    align-items: center;
  }

  .cta-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .header-container {
    padding: 16px 25px;
  }

  .login-btn {
    padding: 10px 20px;
    font-size: 15px;

    .btn-icon {
      font-size: 16px;
    }
  }

  .footer-links {
    gap: 20px;
  }
}

@media (max-width: 640px) {
  .intro-features {
    grid-template-columns: 1fr;
  }

  .intro-title {
    font-size: 28px;
  }

  .intro-subtitle {
    font-size: 16px;
  }

  .intro-desc {
    font-size: 17px;
  }

  ::v-deep .el-carousel--card {
    width: 150% !important;
    margin: 0 -25%;
  }

  .login-buttons {
    gap: 12px;
  }
}

@media (max-width: 500px) {
  .login-btn {
    padding: 10px 18px;

    .btn-text {
      font-size: 15px;
    }
  }

  .carousel-container {
    margin: 20px auto 40px;
    margin-right: 3%;
  }
}
</style>